package com.gxsyh.nantie.permission.provider.service.impl;

import com.gxsyh.nantie.permission.provider.domain.TbUserRole;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.gxsyh.nantie.permission.provider.mapper.TbUserRoleMapper;
import com.gxsyh.nantie.permission.provider.service.TbUserRoleService;
import tk.mybatis.mapper.entity.Example;

/**
 * @email yom535@outlook.com
 * @author: 刘锋嘉(Liu Fengjia)
 * @date: 2020/1/14
 * @time: 17:13
 * @Description: 
 */
@Service
public class TbUserRoleServiceImpl implements TbUserRoleService{

    @Resource
    private TbUserRoleMapper tbUserRoleMapper;

    @Override
    public int insterTbUserRoleByUserId(Long id, Long userId, Long roleId) {
        TbUserRole tbUserRole=new TbUserRole();
        tbUserRole.setId(id);
        tbUserRole.setUserId(userId);
        tbUserRole.setRoleId(roleId);
        return tbUserRoleMapper.insert(tbUserRole);
    }

    @Override
    public int deleteTbUserRoleByUserId(Long userId) {
        Example example=new Example(TbUserRole.class);
        example.createCriteria().andEqualTo("userId",userId);
        return tbUserRoleMapper.deleteByExample(example);
    }
}
